<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="bit.util.ConnectionContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String sql = "SELECT * FROM champ " +
			"ORDER BY no DESC";

Connection conn = ConnectionContext.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);

ResultSet rs = pstmt.executeQuery();

%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>챔프 목록</title>
<script type="text/javascript">
	function confirmDelete(e) {
		if (confirm("정말 삭제하시겠습니까?") == true) {	// '확인'버튼을 누르면
			return true;
		}
		else {
			return false;
		}
	}
</script>
</head>
<body>

<table border="1">
	<tr>
		<th>이름</th><!-- <td align="center"><b></b></td> -->
		<th>타입</th>
		<th>체력</th>
		<th>공격력</th>
		<th>등록일</th>
		<th>관리</th>
	</tr>
<%
while (rs.next()) {
	int no = rs.getInt("no");
	String name = rs.getString("name");
	String type = rs.getString("type");
	int health = rs.getInt("health");
	int damage = rs.getInt("damage");
%>
	<tr>
		<td><%= name %></td>
		<td><%= type %></td>
		<td><%= health %></td>
		<td><%= damage %></td>
		<td><%= rs.getDate("regdate") %></td>
		<td>
			<a href="edit.jsp?no=<%= no %>">수정</a>
			/
			<a href="delete.jsp?no=<%= no %>" onclick="return confirmDelete(event);">삭제</a>
		</td>
	</tr>
<%
}

rs.close();
pstmt.close();
%>
</table>

<a href="add.jsp">신규 등록</a>

</body>
</html>